Page({
  onShareAppMessage() {
    return {
      title: 'WXML节点布局相交状态',
      path: 'packageAPI/pages/page/intersection-observer/intersection-observer'
    }
  },

  data: {
    schema:[
    ],
    formData:{
    },
    theme: 'light',
    appear: false,
    observe: false,
    title: '',
    result: '',
    remark: '',
    webUrl: '',
    apiName: ''
  },
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: options.title,
    })

    this.setData({
      apiType: options.zh,
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    this.setData({
      theme: wx.getSystemInfoSync().theme || 'light'
    })

    if (wx.onThemeChange) {
      wx.onThemeChange(({theme}) => {
        this.setData({theme})
      })
    }
    this._observer = wx.createIntersectionObserver(this)
  },
  onUnload() {
    this.choose2()
  },
  getFormData(e) {
  },
  choose1() {
    this._observer.relativeTo('.scroll-view').observe('.ball', (res) => {
      this.setData({
        appear: res.intersectionRatio > 0,
        result: res
      })
    })
  },
  choose2() {
    if (this._observer) this._observer.disconnect()
  }
})
